package com.cbtx.tablet.adapter

import android.widget.FrameLayout
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.cbtx.tablet.R
import com.cbtx.tablet.bean.GoodsItemBean
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.module.LoadMoreModule
import com.chad.library.adapter.base.viewholder.BaseViewHolder

/**
 * author : joker.peng
 * e-mail : joker@fiture.com
 * date   : 2021/7/21 2:30 PM
 * desc   :
 */
class GoodsAdapter : BaseQuickAdapter<GoodsItemBean, BaseViewHolder> , LoadMoreModule {

    private var width = 283

    constructor() : super(R.layout.item_goods)

    override fun convert(holder: BaseViewHolder, item: GoodsItemBean) {
        val mIvCover: ImageView = holder.getView(R.id.mIvQRCode)
        val layoutParams = mIvCover.layoutParams as FrameLayout.LayoutParams
        layoutParams.width = width
        layoutParams.height = width

        mIvCover.layoutParams = layoutParams

        Glide.with(context)
            .load(item.coverImg)
            .error(R.mipmap.ic_default_small)
            .placeholder(R.mipmap.ic_default_small)
            .into(mIvCover)
    }
}